package second.binarytree;


public class Solution08 {
    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;
        return symmetric(root.left, root.right);
    }

    public boolean symmetric(TreeNode left, TreeNode right) {
        if (left != null && right == null) return false;
        if (left == null && right != null) return false;

        if (right == null && left == null) return true;

        if (right.val != left.val) return false;

        boolean b1 = symmetric(left.left, right.right);
        boolean b2 = symmetric(left.right, right.left);
        return b1 && b2;
    }


}

